<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base],
    components: {
       
    },
    data() {
        return {
            load: true,
            form: {
                // 是否开启 0否 1是
                isOpen: 0,
            },
            // 页面接口地址
            apiUrl: {
                detail: "mall-site-portal/web-config/getItem",
                save: "mall-site-portal/web-config/saveOrUpdate",
            },
            
        };
    },
    methods: {
        // 初始化
        async init() {
            this.getData();
            
        },


        // 获取内容信息
        async getData() {
            this.load = true;
            let _data = await this.$vFN.Http.post(
                {
                    url: this.apiUrl.detail,
                },
                window
            );
            if (_data._ok) {
                for (let i in this.form) {
                    let _d = _data.data[i];
                    if (_d != null) {
                        this.form[i] = _d;
                    }
                }
            }
            this.load = false;
        },
        // 验证
        validate() {
            return new Promise((resolve, reject) => {
                this.$refs["editForm"].validate((valid) => {
                    valid ? resolve(true) : resolve(false);
                });
            });
        },
        // 提交
        async submit() {
            if (!(await this.validate())) {
                return;
            }
            this.load = true;
            let _data = await this.$vFN.Http.post(
                {
                    url: this.apiUrl.save,
                    data: this.form,
                },
                window
            );
            if (_data._ok) {
                this.$vFN.Tools.messageSuccess("操作成功");
                this.init();
            }
            this.load = false;
        },
    },
    mounted() {
        this.init();
    },
    activated() {},
};
</script>